<template>
  <div class="play">
      <audio :src="playPath" ref="audio"
        autoplay
        loop
        controls
        preload
      ></audio>
  </div>
</template>

<script>
export default {
    props:{
       
        playPath:{
            type:String
        },
        isPlay:{
            type:Boolean
        }
    },
    watch:{
        isPlay:{
            immediate:true,
            deep:true,
            handler(val){
                if(val){
                    if(this.$refs['audio']){
                        this.$refs['audio'].play()
                    }
                    
                }else{
                    if(this.$refs['audio']){
                        this.$refs['audio'].pause()
                    }
                    
                }
            }
        }
    },
    create(){
        
    },
    mounted(){
        console.log("==>",this.$refs['audio'])
    }
}
</script>

<style lang="scss" scoped>
.play{
    position: fixed;
    z-index: 10000;
    left: -100%;
    opacity: 0;
    top: 0;
    width: 100%;
    height: 80px;
    background-color: #fff;
}


</style>

